package org.imperativetable;

import java.util.Comparator;

public class Column {

    private final String title;
    private final boolean loadTitleFromMessageResources;
    private final ColumnContent columnContent;
    private final boolean sortable;
    private final Comparator comparator;

    public static class Builder {
        /*
         * Required parameters
         */
        private String title;
        private ColumnContent columnContent;
        /*
         * Optional parameters
         */
        private boolean loadTitleFromMessageResources = false;
        private boolean sortable = false;
        private Comparator comparator = null;

        public Builder(String title, ColumnContent columnContent) {
            this.title = title;
            this.columnContent = columnContent;
        }

        public Builder loadTitleFromMessageResources(boolean loadTitleFromMessageResources) {
            this.loadTitleFromMessageResources = loadTitleFromMessageResources;
            return this;
        }

        public Builder sotrable(boolean sortable) {
            this.sortable = sortable;
            return this;
        }

        public Builder comparator(Comparator comparator) {
            this.comparator = comparator;
            return this;
        }

        public Column build() {
            return new Column(this);
        }
    }

    private Column(Builder builder) {
        title = builder.title;
        loadTitleFromMessageResources = builder.loadTitleFromMessageResources;
        columnContent = builder.columnContent;
        sortable = builder.sortable;
        comparator = builder.comparator;
    }

    public String getTitle() {
        return title;
    }

    public boolean isLoadTitleFromMessageResources() {
        return loadTitleFromMessageResources;
    }

    public ColumnContent getColumnContent() {
        return columnContent;
    }

    public boolean isSortable() {
        return sortable;
    }

    public Comparator getComparator() {
        return comparator;
    }
}
